package zhouzhouyongche.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import zhouzhouyongche.model.Ticket;

@Repository
public class TicketDao extends HibernateDao<Ticket>{

	public List getTicketes(int startCityId, int endCityId, int year, int month, int day) {
		String hql = "select t.busType, t.endSite.siteName, t.inventory, "
				   + "t.price, t.startCity.cityName, t.startPassengerStation.passengerStationName, "
				   + "t.hour.hour, t.minute.minute, t.id, t.busNumber, t.month.month, t.day.day "
				   + "from Ticket as t "
				   + "where t.inventory > 0 "
				   + "and t.startCity.id = ? "
				   + "and t.endCity.id = ? "
				   + "and t.year.year = ? "
				   + "and t.month.month = ? "
				   + "and t.day.day = ? ";
		Query q = getCurrentSession().createQuery(hql);
		q.setInteger(0, startCityId);
		q.setInteger(1, endCityId);
		q.setInteger(2, year);
		q.setInteger(3, month);
		q.setInteger(4, day);
		return q.list();
	}

}
